﻿#pragma once

#include "Const.h"
#include "Snake.h"
#include "SnakeBody.h"

// 游戏状态
typedef enum GameStatus {
    END,    // 已结束
    PAUSED, // 暂停中
    PLAYING // 游戏中
} GameStatus;

typedef struct Game Game;

typedef void (*GameDelete)(Game*);
typedef void (*GamePause)(Game*);
typedef BOOL (*GamePlayMusic)(Game*);
typedef BOOL (*GameOnKeyPress)(Game*, UINT);
typedef void (*GameOnTimer)(Game*);
typedef void(*GameStart)(Game*);

// 游戏
struct Game {
    SnakeBody* mApple;  // 果子
    HWND mCallback;     // 回调
    int mDifficulty;    // 难度
    HDC mDrawer;        // 绘图者
    BOOL mEnableMusic;  // 音乐开关
    HWND mGameBoard;    // 游戏区域
    int mScore;         // 得分
    Snake* mSnake;      // 蛇
    GameStatus mStatus; // 状态

    GameDelete deleteSelf;
    GamePause pause;
    GamePlayMusic playMusic;
    GameOnKeyPress onKeyPressed;
    GameOnTimer onTimer;
    GameStart start;
};

Game* New_Game(HWND, HDC, HWND);
